Document text extraction over HTTP, speaking the Apache Tika server API. Point your TIKA_URL at it and nothing else changes.
It exists because Tika was the slowest thing in our resume pipeline that wasn't an LLM call, and because it threw away every hyperlink in the document. rsparse is a single Rust binary that returns GitHub-Flavored Markdown with the links intact.
Both containers capped at 1 CPU and 1536Mi, same machine (Apple M-series, colima), n=200 sequential requests over loopback, measured with a Go client that issues the same PUT our backend does. The test files are a one-page LaTeX resume PDF (106 KB) and a Word resume (13 KB).
| example-resume.pdf | mean | p50 | p95 | p99 |
|---|---|---|---|---|
| Apache Tika | 9.98 ms | 4.70 | 57.31 | 62.04 |
| rsparse | 1.75 ms | 1.72 | 1.93 | 2.23 |
| example-resume.docx | mean | p50 | p95 | p99 |
|---|---|---|---|---|
| Apache Tika | 16.00 ms | 7.12 | 62.36 | 72.76 |
| rsparse | 1.39 ms | 1.38 | 1.47 | 1.58 |
The gap between Tika's p50 and p95 is JVM garbage collection. It is why its mean is more than twice its median, and it is the part you feel in production. rsparse's p95 sits within a quarter of a millisecond of its p50.
Throughput with 8 concurrent workers: 765 req/s on PDF and 751 req/s on DOCX, against 153 and 90 for Tika.
| Tika | rsparse | |
|---|---|---|
| image size | 604 MB | 58.2 MB |
| memory, idle | 210 MB | 4.7 MB |
| memory, after 400 requests | 354 MB | 71 MB |
| cold start to first parse | 1.62 s | 0.03 s |
Parse cost scales with content rather than file size, at roughly 0.17 ms per page of text after a fixed ~0.09 ms. A 7.7 MB slide deck of scanned images costs less than a dense one-page resume.
Reproduce it against your own documents:
cd bench
go run . -file your-document.pdf \
-a http://localhost:9998/tika -b http://localhost:9996/tika
docker run -p 9998:9998 remotestarai/rsparse:latest
curl -X PUT --data-binary @resume.pdf \
-H "Content-Type: application/pdf" \
-H "Accept: text/plain" \
http://localhost:9998/tika
You get markdown back:
# Ada Lovelace Email:[ada@example.com](mailto:ada@example.com)
[Github](https://github.com/example/ada) [Homepage](https://ada.example.com/)
## Experience
Analytical Engine Project. Wrote the first published algorithm intended for a machine.Tika returns the same text with Github and Homepage as bare words and the URLs gone.
| Route | Method | Purpose |
|---|---|---|
/tika |
PUT | Extract. Body is the raw file. |
/ |
PUT | Same as /tika. |
/health |
GET | Returns ok. |
Request headers: Content-Type names the MIME type, Accept is ignored (the response is always UTF-8 text). The body is the file itself, not multipart.
Responses:
| Status | Meaning |
|---|---|
| 200 | Markdown in the body. |
| 400 | Empty body. |
| 422 | Unsupported format, corrupt file, or a PDF with no text layer. The body says which. |
Configuration:
| Variable | Default | Purpose |
|---|---|---|
LISTEN_ADDR |
0.0.0.0:9998 |
Bind address. |
MAX_BODY_MB |
64 |
Request body limit. |
PDF, DOCX, DOC, XLSX, XLS, PPTX, PPT, ODT, ODS, ODP, RTF, EPUB, CSV.
Spreadsheets come back as markdown tables.
Content is sniffed from the bytes first and the Content-Type header is only a fallback. This is deliberate: the header usually originates in a browser multipart part, where application/octet-stream and outright wrong types are common. A DOCX labelled as a PDF still parses.
The one format that needs an honest Content-Type is CSV, because it has no signature to sniff. Send text/csv or you get a 422.
Output is markdown, not flat text. Headings, lists, tables, and links. Better input for an LLM, but if you have prompts tuned against Tika's flat output, check a batch of documents before you switch.
Hyperlinks survive. See below for why that took work.
Scanned PDFs fail with a 422 instead of returning 200 and an empty body. Tika (without the tesseract-enabled image) answers 200 with nothing in it, which reaches your model as a blank document. rsparse says PDF has no extractable text (scanned or image-only): OCR is required so you can route to OCR. There is no OCR in rsparse itself.
PDFs keep hyperlinks in an annotation layer that sits beside the text, not in the text. Text extractors read the text and leave the annotations behind, which is why almost every PDF-to-text tool loses your URLs.
pdf-inspector actually reports them. Every annotation comes back as a positioned item with ItemType::Link(url) and a rect, in the same coordinate space as the text items. Its markdown writer then collects those items into a vector and never reads it, so include_links: true does nothing today. The data is there; the emission is missing.
So rsparse takes one extraction pass, feeds the items to the markdown writer, and separately overlaps the link rects with the text rects to recover each anchor. Two details matter and both took a debugging round to find:
Ordering is not a plain y sort. Annotation rects on one visual line can differ by a point or two, and sorting on raw y interleaves them, which lands the anchors on the wrong text. Items get bucketed into line bands first, then ordered by x.
Matching needs one document-wide cursor, not one per anchor. A resume says "Github" three times. Matching each link independently lets a link from the projects section claim the header's text and emit [[Github](url): handle](url). A single forward-only cursor works because links and text agree on reading order.
If upstream ever emits links itself, src/links.rs deletes cleanly.
cargo run --release --example profile -- yourfile.pdf prints the phase breakdown. On the one-page resume:
extract_text_with_positions_mem 1.031 ms
to_markdown_from_items 0.148 ms
links::splice 0.004 ms
parse (total) 1.119 ms
Extraction is 92% of it, so that is the only place worth optimizing. HTTP framing measures 0.09 ms, which is noise by comparison.
Things that helped: mimalloc as the global allocator (18% off both paths, at the cost of a few MB of RSS), and lto = "fat" with codegen-units = 1 (another 3%).
Things that did not, and why they are not in the code: jemalloc was 20% slower than mimalloc here. Parsing inline instead of on spawn_blocking saved nothing sequentially and was slightly worse at p99 under load. Cloning the item vector before handing it to the markdown writer costs 0.001 ms, so removing the clone is not worth the awkwardness. panic = "abort" would shave a little, but this service parses untrusted uploads and a panic in a PDF parser should return a 422, not take the process down.
Left on the table, in upstream: extract_text_with_positions_mem computes table rects and line groupings and then discards them, because the variant that returns them is pub(crate). Exposing it would give better table detection for free, since the work already happens.
Compose, for local development next to your app:
services:
rsparse:
image: remotestarai/rsparse:latest
ports:
- "9998:9998"Kubernetes manifests are in deploy/kubernetes.yaml. They are a straight swap for a Tika deployment in the same namespace, keeping the service name and port so callers need no change. The resource requests drop from 512Mi to 64Mi because the process idles at under 5 MB and peaks around 71 MB under sustained load.
cargo test
cargo run # listens on 0.0.0.0:9998
docker build -t rsparse .
Tests cover extraction, link splicing, the nesting bug described above, and format sniffing when the header lies. Fixtures in tests/fixtures are synthetic documents, not real resumes.
CI runs the tests on every push and pull request, but it publishes nothing. Images go to Docker Hub only when you push a release tag:
git tag v0.2.1 && git push origin v0.2.1
That builds linux/amd64 and linux/arm64 on their own native runners, pushes each by digest, and only then stitches them into one multi-arch tag. A half-finished matrix cannot publish a broken tag. A non-prerelease tag also moves :latest; v0.2.1-rc1 does not.
The parsing is not ours. anydoc and pdf-inspector, both from Firecrawl and both MIT, do the actual work. rsparse is an HTTP shim, a link splicer, and a Dockerfile.
MIT. See LICENSE.