optimization

optimizing byte-pair encoding

泪湿孤枕 提交于 2020-01-10 10:53:06
问题 Noticing that byte-pair encoding (BPE) is sorely lacking from the large text compression benchmark, I very quickly made a trivial literal implementation of it. The compression ratio - considering that there is no further processing, e.g. no Huffman or arithmetic encoding - is surprisingly good. The runtime of my trivial implementation was less than stellar, however. How can this be optimized? Is it possible to do it in a single pass? 回答1: This is a summary of my progress so far: Googling

optimizing byte-pair encoding

廉价感情. 提交于 2020-01-10 10:52:49
问题 Noticing that byte-pair encoding (BPE) is sorely lacking from the large text compression benchmark, I very quickly made a trivial literal implementation of it. The compression ratio - considering that there is no further processing, e.g. no Huffman or arithmetic encoding - is surprisingly good. The runtime of my trivial implementation was less than stellar, however. How can this be optimized? Is it possible to do it in a single pass? 回答1: This is a summary of my progress so far: Googling

optimizing byte-pair encoding

二次信任 提交于 2020-01-10 10:52:36
问题 Noticing that byte-pair encoding (BPE) is sorely lacking from the large text compression benchmark, I very quickly made a trivial literal implementation of it. The compression ratio - considering that there is no further processing, e.g. no Huffman or arithmetic encoding - is surprisingly good. The runtime of my trivial implementation was less than stellar, however. How can this be optimized? Is it possible to do it in a single pass? 回答1: This is a summary of my progress so far: Googling

Optimize PostgreSQL read-only tables

一笑奈何 提交于 2020-01-10 10:41:50
问题 I have many read-only tables in a Postgres database. All of these tables can be queried using any combination of columns. What can I do to optimize queries? Is it a good idea to add indexes to all columns to all tables? 回答1: Columns that are used for filtering or joining (or, to a lesser degree, sorting ) are of interest for indexing. Columns that are just selected are barely relevant! For the following query only indexes on a and e may be useful: SELECT a,b,c,d FROM tbl_a WHERE a = $some

DataTable.Select vs DataTable.rows.Find vs foreach vs Find(Predicate<T>)/Lambda

懵懂的女人 提交于 2020-01-10 07:58:29
问题 I have a DataTable/collection that is cached in memory, I want to use this as a source to generate results for an auto complete textbox (using AJAX of course). I am evaluating various options to fetch the data quickly. The number of items in the collection/rows in the datatable could vary from 10000 to 2,000,000. (So that we dont get diverted, for the moment assume that the decision has been made, I have ample RAM and I will be using the cache and not database query for this) I have some

Python App Engine webapp2 slow to route

眉间皱痕 提交于 2020-01-10 03:11:11
问题 I have a Python App Engine application which serves about 3M requests per day. I am trying to optimize the app to save on my ridiculously ballooned hosting bill. November, App Engine Frontend Instances: 12924.391 Hours, $604.22 I have the request handling down to some memcached calls, but now I've noticed that it usually takes about 20ms, sometimes as long as 166ms before webapp2 even passes the request to me. In the image below you can see a Trace showing "Post" happening at 166ms. Here is

Fast undo/redo for bitmap editor when memory is limited?

僤鯓⒐⒋嵵緔 提交于 2020-01-09 19:48:11
问题 I'm trying to write a bitmap editor for a mobile device (i.e. a limited version of Photoshop). The user's document consists of ~4 bitmaps around 1000x500 in size each. I want a robust and efficient undo/redo system that's as simple as possible. I'm aiming for about ~0.2s to undo or redo an edit. I'm looking for some feedback on my current intended approach or for some new ideas I can use. I think what I have is too complex so I'm cautious about proceeding so just knowing it's about the best I

Finding the minimal coverage of an interval with subintervals

梦想与她 提交于 2020-01-09 19:29:46
问题 Suppose I have an interval (a,b), and a number of subintervals {(a i ,b i )} i whose union is all of (a,b). Is there an efficient way to choose a minimal-cardinality subset of these subintervals which still covers (a,b)? 回答1: A greedy algorithm starting at a or b always gives the optimal solution. Proof: consider the set S a of all the subintervals covering a. Clearly, one of them has to belong to the optimal solution. If we replace it with a subinterval (a max ,b max ) from S a whose right

Finding the minimal coverage of an interval with subintervals

僤鯓⒐⒋嵵緔 提交于 2020-01-09 19:29:27
问题 Suppose I have an interval (a,b), and a number of subintervals {(a i ,b i )} i whose union is all of (a,b). Is there an efficient way to choose a minimal-cardinality subset of these subintervals which still covers (a,b)? 回答1: A greedy algorithm starting at a or b always gives the optimal solution. Proof: consider the set S a of all the subintervals covering a. Clearly, one of them has to belong to the optimal solution. If we replace it with a subinterval (a max ,b max ) from S a whose right

jQuery selector optimization

情到浓时终转凉″ 提交于 2020-01-09 12:48:40
问题 Be specific on the right-hand side of your selector, and less specific on the left. // unoptimized $('div.data .gonzalez'); // optimized $('.data td.gonzalez'); Quote Source Could someone explain why the less specific left is faster as a CSS selector? Is this a Sizzle thing or does the same apply for document.querySelectorAll ? Are there any speed gains using "similarly optimised" CSS selectors in CSS files? 回答1: jQuery's Sizzle Engine parse selectors from right to left, so it's true. There