Skip to content

Instantly share code, notes, and snippets.

View irrationalRock's full-sized avatar

Matt Q irrationalRock

View GitHub Profile
@irrationalRock
irrationalRock / also-nonvector.c
Created April 22, 2018 21:35
another-nonvector comes from here
/* Stores the hash of the next 4 bytes and in a single tree-traversal, the
hash bucket's binary tree is searched for matches and is re-rooted at the
current position.
If less than MAX_TREE_COMP_LENGTH data is available, the hash bucket of the
current position is searched for matches, but the state of the hash table
is not changed, since we can not know the final sorting order of the
current (incomplete) sequence.
This function must be called with increasing cur_ix positions. */
static BROTLI_INLINE BackwardMatch* FN(StoreAndFindMatches)(
HashToBinaryTree* self, const uint8_t* const BROTLI_RESTRICT data,
@irrationalRock
irrationalRock / another-nonvector.c
Created April 22, 2018 21:32
non-vector.c comes from here
/* Stores the hash of the next 4 bytes and re-roots the binary tree at the
current sequence, without returning any matches.
REQUIRES: ix + MAX_TREE_COMP_LENGTH <= end-of-current-block */
static BROTLI_INLINE void FN(Store)(HasherHandle handle, const uint8_t* data,
const size_t mask, const size_t ix) {
HashToBinaryTree* self = FN(Self)(handle);
/* Maximum distance is window size - 16, see section 9.1. of the spec. */
const size_t max_backward = self->window_mask_ - BROTLI_WINDOW_GAP + 1;
FN(StoreAndFindMatches)(self, data, ix, mask, MAX_TREE_COMP_LENGTH,
max_backward, NULL, NULL);
@irrationalRock
irrationalRock / non-vector.c
Created April 21, 2018 19:08
non vectored method
static BROTLI_INLINE void FN(StoreRange)(HasherHandle handle,
const uint8_t* data, const size_t mask, const size_t ix_start,
const size_t ix_end) {
size_t i = ix_start;
size_t j = ix_start;
if (ix_start + 63 <= ix_end) {
i = ix_end - 63;
}
if (ix_start + 512 <= i) {
for (; j < i; j += 8) {
@irrationalRock
irrationalRock / finalSolution.js
Created April 21, 2018 02:13
doing some fixes
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const primaryCursor = editor.getSelection();
const allSelections = editor.getSelections();
const model = editor.getModel();
let rangeAll = [];
for(let i = 0; i < allSelections.length;i++){
rangeAll.push(model.getLineContent(allSelections[i].selectionStartLineNumber));
}
@irrationalRock
irrationalRock / BrotliParseAsUTF8.c
Created April 18, 2018 02:43
BrotliParseAsUTF8(14.90)
static size_t BrotliParseAsUTF8(
int* symbol, const uint8_t* input, size_t size) {
/* ASCII */
if ((input[0] & 0x80) == 0) {
*symbol = input[0];
if (*symbol > 0) {
return 1;
}
}
/* 2-byte UTF8 */
@irrationalRock
irrationalRock / BrotliIsMostlyUTF8.c
Created April 18, 2018 02:41
BrotliIsMostlyUTF8(25.06)
BROTLI_BOOL BrotliIsMostlyUTF8(
const uint8_t* data, const size_t pos, const size_t mask,
const size_t length, const double min_fraction) {
size_t size_utf8 = 0;
size_t i = 0;
while (i < length) {
int symbol;
size_t bytes_read =
BrotliParseAsUTF8(&symbol, &data[(pos + i) & mask], length - i);
i += bytes_read;
@irrationalRock
irrationalRock / BrotliEstimateBitCostsForLiterals.c
Created April 18, 2018 02:40
BrotliEstimateBitCostsForLiterals(18.24)
void BrotliEstimateBitCostsForLiterals(size_t pos, size_t len, size_t mask,
const uint8_t* data, float* cost) {
if (BrotliIsMostlyUTF8(data, pos, mask, len, kMinUTF8Ratio)) {
EstimateBitCostsForLiteralsUTF8(pos, len, mask, data, cost);
return;
} else {
size_t histogram[256] = { 0 };
size_t window_half = 2000;
size_t in_window = BROTLI_MIN(size_t, window_half, len);
@irrationalRock
irrationalRock / aarchie vs ccharlie data.txt
Last active April 9, 2018 20:42
aarchie vs ccharlie data
Aarchie:
Just with –O2:
Run #1
Real 0m49.034s
User 0m48.777s
Run #2
Real 0m49.065s
User 0m48.691s
@irrationalRock
irrationalRock / xerxes.txt
Last active April 9, 2018 15:00
xerxes data
Benchmark -O2(180mb file):
Run#1
Real 0m41.442s
User 0m41.200s
Run#2
Real 0m41.404s
User 0m41.136s
AVG:
@irrationalRock
irrationalRock / stage2.txt
Created April 9, 2018 00:59
stage 2 data
*Aarchie with 180mb file
-Just with -O2:
real 2m51.523s
user 2m51.247s
Number of options tested: 1284
Real best time: 2m50.799s (CMAKE_CXX_FLAGS_DEBUG:STRING= -O2 -ftree-loop-distribute-patterns -floop-interchange -ftree-slp-vectorize -fipa-cp-clone)
User best time: 2m50.367s (CMAKE_CXX_FLAGS_DEBUG:STRING= -O2 -ftree-loop-distribution -ftree-loop-distribute-patterns -fvect-cost-model -ftree-partial-pre)
**************************************************************************************************************************