Profiler output suggests that forward-match is a bit expensive. Here
is profiler output from the original code, when profiler is wrapped
around tabify-selection:
------------------------------------------------------------------------------------------------------------
loop [34] 0.1%
get-backward-sexp method in ...k/private/racket.rkt:425:2 [28] 99.9%
[37] 50648(61.1%) 0(0.0%) stick-to-next-sexp? method in ...k/private/racket.rkt:425:2 ...
do-forward-match method in ...rk/private/color.rkt:71:2 [50] 99.9%
...
------------------------------------------------------------------------------------------------------------
get-forward-sexp method in ...k/private/racket.rkt:425:2 [38] 17.1%
stick-to-next-sexp? method in ...k/private/racket.rkt:425:2 [37] 82.9%
[50] 61043(73.6%) 53(0.1%) do-forward-match method in ...rk/private/color.rkt:71:2 ...
colorer-driver method in ...rk/private/color.rkt:71:2 [66] 99.8%
match-forward method in paren-tree% [72] 0.1%
------------------------------------------------------------------------------------------------------------
The patch does the prerequisite string matching before calling forward-match.
Reference to dev list: http://lists.racket-lang.org/dev/archive/2012-November/010976.html
A few invariants involving subtree-width and black-height balance
could break if singleton nodes were reused; bugs were due to stale
data in the nodes.
The token tree implements the implicit interface in the original
splay-based token tree module in syntax-color/token-tree. However, it
does not appear to perform significantly differently in the case of
indentation yet. It needs some additional profiling and analysis to
see if we can take advantage of the richer structure in the rb tree.
Synchronous mode implies fsync(), which makes updates *much*
slower on some machines, such as the DrDr machine. The doc
database doesn't need to survive a catastrophic failue
(such as a power failure or OS crash), so turn synchronous
mode off.
Handle close parentheses in a smarter way while in
auto-parens mode and be a little more smart about
inserting brace pairs in general.
In summary:
- Add some "smart-skip" behavior to insert-close-paren,
described in the documentation.
- When auto-parens mode is enabled,
the existing "balance-parens" keybinding invokes
insert-close-paren with a smart-skip argument of
'adjacent
- A new "balance-parens-forward" keybinding invokes
insert-close-paren with a smart-skip argument of
'forward (whether or not auto-parens mode is
enabled)
- Enable basic smart-skip behavior for
strings ("...") and |...| pairs, specifically, typing
a double-quote or bar character when the cursor
immediately precedes one causes the cursor to simply
skip over the existing one
- Tweak auto-insertion of block comment pairs; i.e.
typing hash and a bar results in a properly balanced
#||# pair. Also, when you type a bar character when
the cursor immediately precedes a closing bar and
hash of a comment, then the cursor skips over both
characters (this seems better than having it just
skip over the bar, and then having to introduce a
new keybinding to detect when a hash is typed while
the cursor is between a bar and a hash)
- In strings and line/block comments, auto-parens mode
no longer has any effect (you can still use the M+..
keybindings to force insertion of a particular brace
pair)
- Detect when a character constant is being typed, and
don't insert brace pairs if so; i.e. if the cursor
is immediately after #\ , then typing any open parens,
double quote, or bar, does _not_ result in the
insertion of an open/close pair even in auto-parens
mode
- Add a bunch of tests related to auto-parens, matching
pairs of braces, strings, comments, etc. to
collects/tests/framework/racket.rkt
Changes the implementation of highlight-range so that it
only recomputes all of the new locations from the positions
when on-reflow is called (otherwise only computing the
relevant ones) and make the on-reflow callback chop itself
up, in case there are lots of highlighted ranges to avoid
tying up the event loop.
Changes searching so that it doesn't neccessarily compute
the entire search results in a single event callback
(but also make it start the computation more aggressively)
Overall, this changes the strategy from one that, for any potentially
long-running callback, just tried to push it off into the future, into
a strategy that tries to avoid long-running callbacks by breaking the
work up into chunks, but starting the first chunk immediately (in a
low-priority callback).
Also, misc other changes to make this work better and generally clean
things up.
Specifically, when a style change happens that ends up
not changing the size of anything, then track that
lack of size change enough to be able to avoid
calling on-reflow.
This is important for the interaction between the
colorer and the search bubbles in DrRacket. That is,
when you make an edit that causes the colorer to have
lots of work, then each chunk of work it does before
yielding control to the event loop would also trigger
a call to on-reflow, which would cause the search bubbles
to recompute their sizes. Overall, the main bad thing
this does is cause lots of allocation and aside from
that it doesn't hurt interactivity. Still, there is a
lot of useless work here, and those extra GCs can be
pretty substantial when you're doing something crazy like
searching for " " in a big file.... (there are 95k spaces
in unit.rkt, in case you were curious)
Change `raco setup' to guard database writes in different places
by an explicit lock that is implemented by place channels. Change
corss-reference reading to fall back to just loading ".sxref"
files if the database seems to be too contended at that point.
These changes are aimed at avoiding distaerous performance when
SQLite seems not to behave well.
Also, fix break and other exception handling near the "fast abort"
path for both reads and writes.
Replaced pointwise operators with macros that expand to applications of `array-map'; allows more precise return types and reduces compilation time
Changed literal array syntax to use #() to delimit rows instead of [] (still suggest using square parens, though)
Minor refactoring
Fixed a macro so that the only problem with "array-tests.rkt" now is that typed/rackunit is b0rked
This change makes document building --- and specially incremental
document building --- more scalable. The global duplicate-definition
check is handled by a database query, for example.
For example, the cross-reference information for the
Reference is now broken into about 16 pieces, so that
resolving a cross-reference into the Reference doesn't
require loading all cross-reference information for
the Reference.
Every document is split into two pieces, so that the title
of a document is roughly in its own piece. That way,
re-building the page of all installed documentation can be more
scalable (after some further changes).
Typically, the bluebox table includes keys that have interned parts,
so serialization can save space both on disk and in memory when the
bluebox information is reloaded.
Loading `db/sqlite3' no longer raises an exception if
the SQLite library isn't found. Instead, `sqlite3-connect'
raises an exception, while `sqlite3-available?' reports
whether it will work.
The dynamic test allows the documentation-help system
to continue to work if SQLite3 is not available. Currently,
though, `raco setup' still insists on using SQLite3 to
build the database of documented tags.